package de.lm.android.jogging;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class LaufActivity extends Activity {

	private TextView timer;
	private Button startButton, stopButton;
	private StopWatch stopUhr;
	private static long MINS, SECS;
	private String minuten, sekunden;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.lauf);

		timer = (TextView) findViewById(R.id.timer);
		startButton = (Button) findViewById(R.id.startButton);
		stopButton = (Button) findViewById(R.id.stopButton);
		stopUhr = new StopWatch();
		stopButton.setEnabled(false);

		startButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				stopUhr.start();
				timer.setText("aktiv");
				startButton.setEnabled(false);
				stopButton.setEnabled(true);
			}
		});

		stopButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				stopUhr.stop();
				MINS = (stopUhr.getElapsedTimeMins());
				SECS = (stopUhr.getElapsedTimeSecs());
				minuten = String.valueOf(MINS);
				sekunden = String.valueOf(SECS);
				timer.setText("Zeit: " + minuten + "min " + sekunden + "sek");
				stopButton.setEnabled(false);
				startButton.setEnabled(true);
			}

		});

	}

}